<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified">
  <xs:element name="E_Invoice">
    <xs:annotation>
      <xs:documentation>root element</xs:documentation>
    </xs:annotation>
    <xs:complexType>
      <xs:sequence>
        <xs:element ref="Header"/>
        <xs:element ref="Invoice" maxOccurs="unbounded"/>
      </xs:sequence>
    </xs:complexType>
  </xs:element>
  <xs:element name="Header">
    <xs:complexType>
      <xs:sequence>
        <xs:element name="Test" type="YesNoType" minOccurs="0"/>
        <xs:element name="Date" type="DateType"/>
        <xs:element name="FileId" type="ShortTextType"/>
        <xs:element name="Version" type="ShortTextType"/>
        <xs:element name="SenderId" type="ShortTextType" minOccurs="0"/>
        <xs:element name="ReceiverId" type="ShortTextType" minOccurs="0"/>
        <xs:element name="ContractId" type="ShortTextType" minOccurs="0"/>
        <xs:element name="PayeeAccountNumber" type="AccountType" minOccurs="0"/>
        <xs:element name="TotalNumberInvoices" type="xs:positiveInteger"/>
        <xs:element name="TotalAmount" type="Decimal2FractionDigitsType"/>
      </xs:sequence>
    </xs:complexType>
  </xs:element>
  <xs:element name="Invoice">
    <xs:complexType>
      <xs:sequence>
        <xs:element ref="InvoiceParties"/>
        <xs:element ref="InvoiceInformation"/>
        <xs:element ref="InvoiceSumGroup" maxOccurs="2"/>
        <xs:element ref="InvoiceItem"/>
        <xs:element ref="AdditionalInformation" minOccurs="0" maxOccurs="unbounded"/>
        <xs:element ref="PaymentInfo"/>
      </xs:sequence>
      <xs:attribute name="invoiceId" type="NormalTextType" use="required"/>
      <xs:attribute name="serviceId" type="ShortTextType" use="required"/>
      <xs:attribute name="regNumber" type="RegType" use="required"/>
      <xs:attribute name="accountNumber" type="AccountType" use="required"/>
      <xs:attribute name="factoring" type="YesNoType" use="optional"/>
    </xs:complexType>
  </xs:element>
  <xs:element name="InvoiceParties">
    <xs:complexType>
      <xs:sequence>
        <xs:element name="SellerParty" type="BillPartyRecord"/>
        <xs:element name="BuyerParty" type="BillPartyRecord"/>
        <xs:element name="RecipientParty" type="BillPartyRecord" minOccurs="0"/>
        <xs:element name="DeliveryParty" type="BillPartyRecord" minOccurs="0"/>
      </xs:sequence>
    </xs:complexType>
  </xs:element>
  <xs:element name="InvoiceInformation">
    <xs:complexType>
      <xs:sequence>
        <xs:element name="Type">
          <xs:complexType>
            <xs:sequence>
              <xs:element name="SourceInvoice" type="ShortTextType" minOccurs="0"/>
            </xs:sequence>
            <xs:attribute name="type" use="required">
              <xs:simpleType>
                <xs:restriction base="xs:NMTOKEN">
                  <xs:pattern value="DEB"/>
                  <xs:pattern value="CRE"/>
                </xs:restriction>
              </xs:simpleType>
            </xs:attribute>
          </xs:complexType>
        </xs:element>
        <xs:element name="FactorContractNumber" type="NormalTextType" minOccurs="0"/>
        <xs:element name="ContractNumber" type="NormalTextType" minOccurs="0"/>
        <xs:element name="DocumentName" type="NormalTextType" minOccurs="0"/>
        <xs:element name="InvoiceNumber" type="NormalTextType"/>
        <xs:element name="InvoiceContentCode" type="ShortTextType" minOccurs="0"/>
        <xs:element name="InvoiceContentText" type="NormalTextType" minOccurs="0"/>
        <xs:element name="PaymentReferenceNumber" type="ReferenceType" minOccurs="0"/>
        <xs:element name="PaymentMethod" type="NormalTextType" minOccurs="0"/>
        <xs:element name="InvoiceDate" type="DateType"/>
        <xs:element name="DueDate" type="DateType" minOccurs="0"/>
        <xs:element name="FineRatePerDay" type="Decimal2FractionDigitsType" minOccurs="0"/>
        <xs:element name="Period" minOccurs="0">
          <xs:complexType>
            <xs:sequence>
              <xs:element name="PeriodName" type="NormalTextType" minOccurs="0"/>
              <xs:element name="StartDate" type="DateType" minOccurs="0"/>
              <xs:element name="EndDate" type="DateType" minOccurs="0"/>
            </xs:sequence>
          </xs:complexType>
        </xs:element>
        <xs:element name="Extension" type="ExtensionRecord" minOccurs="0" maxOccurs="unbounded"/>
      </xs:sequence>
    </xs:complexType>
  </xs:element>
  <xs:element name="InvoiceSumGroup">
    <xs:complexType>
      <xs:sequence>
        <xs:element name="Balance" minOccurs="0">
          <xs:complexType>
            <xs:sequence>
              <xs:element name="BalanceDate" type="DateType" minOccurs="0"/>
              <xs:element name="BalanceBegin" type="Decimal2FractionDigitsType" minOccurs="0"/>
              <xs:element name="BalanceEnd" type="Decimal2FractionDigitsType" minOccurs="0"/>
            </xs:sequence>
          </xs:complexType>
        </xs:element>
        <xs:element name="InvoiceSum" type="Decimal4FractionDigitsType" minOccurs="0"/>
        <xs:element name="PenaltySum" type="Decimal4FractionDigitsType" minOccurs="0"/>
        <xs:element name="Addition" type="AdditionRecord" minOccurs="0" maxOccurs="unbounded"/>
        <xs:element name="Rounding" type="Decimal4FractionDigitsType" minOccurs="0"/>
        <xs:element name="VAT" type="VATRecord" minOccurs="0" maxOccurs="unbounded"/>
        <xs:element name="TotalSum" type="Decimal2FractionDigitsType"/>
        <xs:element name="Currency" type="CurrencyType" minOccurs="0"/>
        <xs:element name="Accounting" type="AccountingRecord" minOccurs="0"/>
        <xs:element name="Extension" type="ExtensionRecord" minOccurs="0" maxOccurs="unbounded"/>
      </xs:sequence>
    </xs:complexType>
  </xs:element>
  <xs:element name="InvoiceItem">
    <xs:complexType>
      <xs:sequence>
        <xs:element ref="InvoiceItemGroup" maxOccurs="unbounded"/>
      </xs:sequence>
    </xs:complexType>
  </xs:element>
  <xs:element name="InvoiceItemGroup">
    <xs:complexType>
      <xs:sequence>
        <xs:element ref="ItemEntry" maxOccurs="unbounded"/>
        <xs:element ref="GroupEntry" minOccurs="0"/>
      </xs:sequence>
      <xs:attribute name="groupId" type="ShortTextType" use="optional"/>
    </xs:complexType>
  </xs:element>
  <xs:element name="ItemEntry">
    <xs:complexType>
      <xs:sequence>
        <xs:element name="SerialNumber" type="ShortTextType" minOccurs="0"/>
        <xs:element name="Code" type="ShortTextType" minOccurs="0"/>
        <xs:element name="Accounting" type="AccountingRecord" minOccurs="0"/>
        <xs:element name="CustomerRef" type="NormalTextType" minOccurs="0"/>
        <xs:element name="Description" type="LongTextType"/>
        <xs:element name="EAN" type="NormalTextType" minOccurs="0"/>
        <xs:element name="InitialReading" type="ShortTextType" minOccurs="0"/>
        <xs:element name="FinalReading" type="ShortTextType" minOccurs="0"/>
        <xs:element name="ItemReserve" type="ExtensionRecord" minOccurs="0" maxOccurs="unbounded"/>
        <xs:element name="ItemUnit" type="ShortTextType" minOccurs="0"/>
        <xs:element name="ItemAmount" type="Decimal4FractionDigitsType" minOccurs="0"/>
        <xs:element name="ItemPrice" type="Decimal4FractionDigitsType" minOccurs="0"/>
        <xs:element name="ItemSum" type="Decimal4FractionDigitsType" minOccurs="0"/>
        <xs:element name="Addition" type="AdditionRecord" minOccurs="0" maxOccurs="unbounded"/>
        <xs:element name="VAT" type="VATRecord" minOccurs="0"/>
        <xs:element name="ItemTotal" type="Decimal4FractionDigitsType"/>
      </xs:sequence>
    </xs:complexType>
  </xs:element>
  <xs:element name="GroupEntry">
    <xs:complexType>
      <xs:sequence>
        <xs:element name="GroupDescription" type="NormalTextType" minOccurs="0"/>
        <xs:element name="Extension" type="ExtensionRecord" minOccurs="0" maxOccurs="unbounded"/>
        <xs:element name="Accounting" type="AccountingRecord" minOccurs="0"/>
        <xs:element name="GroupAmount" type="Decimal4FractionDigitsType" minOccurs="0"/>
        <xs:element name="GroupSum" type="Decimal4FractionDigitsType" minOccurs="0"/>
        <xs:element name="Addition" type="AdditionRecord" minOccurs="0" maxOccurs="unbounded"/>
        <xs:element name="VAT" type="VATRecord" minOccurs="0"/>
        <xs:element name="GroupTotal" type="Decimal4FractionDigitsType"/>
      </xs:sequence>
    </xs:complexType>
  </xs:element>
  <xs:element name="AdditionalInformation" type="ExtensionRecord"/>
  <xs:element name="PaymentInfo">
    <xs:complexType>
      <xs:sequence>
        <xs:element name="Currency" type="CurrencyType"/>
        <xs:element name="PaymentRefId" type="ReferenceType" minOccurs="0"/>
        <xs:element name="PaymentDescription" minOccurs="0">
          <xs:simpleType>
            <xs:restriction base="xs:string">
              <xs:maxLength value="210"/>
              <xs:pattern value="[&#x0020;-&#x00FF;]*"/>
            </xs:restriction>
          </xs:simpleType>
        </xs:element>
        <xs:element name="Payable" type="YesNoType"/>
        <xs:element name="PayDueDate" type="DateType" minOccurs="0"/>
        <xs:element name="PaymentTotalSum" type="Decimal2FractionDigitsType"/>
        <xs:element name="PayerName" type="NameTextType"/>
        <xs:element name="PaymentId" type="xs:integer"/>
        <xs:element name="PayToAccount" type="AccountType"/>
        <xs:element name="PayToName" type="NameTextType"/>
        <xs:element name="DirectDebitPayeeContractNumber" type="ShortTextType" minOccurs="0"/>
        <xs:element name="DirectDebitPayerNumber" type="ReferenceType" minOccurs="0"/>
      </xs:sequence>
    </xs:complexType>
  </xs:element>
  <xs:complexType name="AccountDataRecord">
    <xs:sequence>
      <xs:element name="AccountNumber" type="AccountType"/>
      <xs:element name="IBAN" type="AccountType" minOccurs="0"/>
      <xs:element name="BIC" minOccurs="0">
        <xs:simpleType>
          <xs:restriction base="xs:string">
            <xs:maxLength value="11"/>
          </xs:restriction>
        </xs:simpleType>
      </xs:element>
      <xs:element name="BankName" minOccurs="0">
        <xs:simpleType>
          <xs:restriction base="NameTextType"/>
        </xs:simpleType>
      </xs:element>
    </xs:sequence>
  </xs:complexType>
  <xs:complexType name="AccountingRecord">
    <xs:sequence>
      <xs:element name="Description" type="NormalTextType" minOccurs="0"/>
      <xs:element name="JournalEntry" maxOccurs="unbounded">
        <xs:complexType>
          <xs:sequence>
            <xs:element name="GeneralLedger" type="ShortTextType" minOccurs="0"/>
            <xs:element name="GeneralLedgerDetail" type="ShortTextType" minOccurs="0"/>
            <xs:element name="CostObjective" type="ShortTextType" minOccurs="0"/>
            <xs:element name="Sum" type="Decimal4FractionDigitsType" minOccurs="0"/>
            <xs:element name="VatSum" type="Decimal4FractionDigitsType" minOccurs="0"/>
            <xs:element name="VatRate" type="Decimal2FractionDigitsType" minOccurs="0"/>
          </xs:sequence>
        </xs:complexType>
      </xs:element>
    </xs:sequence>
  </xs:complexType>
  <xs:complexType name="AdditionRecord">
    <xs:sequence>
      <xs:element name="AddContent" type="NormalTextType"/>
      <xs:element name="AddRate" type="Decimal2FractionDigitsType" minOccurs="0"/>
      <xs:element name="AddSum" type="Decimal4FractionDigitsType"/>
    </xs:sequence>
    <xs:attribute name="addCode" use="required">
      <xs:simpleType>
        <xs:restriction base="xs:NMTOKEN">
          <xs:pattern value="DSC"/>
          <xs:pattern value="CHR"/>
        </xs:restriction>
      </xs:simpleType>
    </xs:attribute>
  </xs:complexType>
  <xs:complexType name="AddressRecord">
    <xs:sequence>
      <xs:element name="PostalAddress1" type="NormalTextType"/>
      <xs:element name="PostalAddress2" type="NormalTextType" minOccurs="0"/>
      <xs:element name="City" type="NormalTextType"/>
      <xs:element name="PostalCode" minOccurs="0">
        <xs:simpleType>
          <xs:restriction base="xs:string">
            <xs:maxLength value="10"/>
          </xs:restriction>
        </xs:simpleType>
      </xs:element>
      <xs:element name="Country" type="NormalTextType" minOccurs="0"/>
      <xs:element name="Extension" type="ExtensionRecord" minOccurs="0" maxOccurs="unbounded"/>
    </xs:sequence>
  </xs:complexType>
  <xs:complexType name="BillPartyRecord">
    <xs:sequence>
      <xs:element name="UniqueCode" type="ShortTextType" minOccurs="0"/>
      <xs:element name="Name" type="NameTextType"/>
      <xs:element name="DepId" type="NormalTextType" minOccurs="0"/>
      <xs:element name="RegNumber" type="RegType" minOccurs="0"/>
      <xs:element name="VATRegNumber" type="RegType" minOccurs="0"/>
      <xs:element name="ContactData" type="ContactDataRecord" minOccurs="0"/>
      <xs:element name="AccountInfo" type="AccountDataRecord" minOccurs="0" maxOccurs="unbounded"/>
      <xs:element name="Extension" type="ExtensionRecord" minOccurs="0" maxOccurs="unbounded"/>
    </xs:sequence>
  </xs:complexType>
  <xs:complexType name="ContactDataRecord">
    <xs:sequence>
      <xs:element name="ContactName" type="NameTextType" minOccurs="0"/>
      <xs:element name="ContactPersonCode" type="RegType" minOccurs="0"/>
      <xs:element name="PhoneNumber" type="NormalTextType" minOccurs="0"/>
      <xs:element name="FaxNumber" type="NormalTextType" minOccurs="0"/>
      <xs:element name="E-mailAddress" minOccurs="0">
        <xs:simpleType>
          <xs:restriction base="xs:string">
            <xs:pattern value=".+@.+"/>
          </xs:restriction>
        </xs:simpleType>
      </xs:element>
      <xs:element name="LegalAddress" type="AddressRecord" minOccurs="0"/>
      <xs:element name="MailAddress" type="AddressRecord" minOccurs="0"/>
      <xs:element name="ContactInformation" type="ExtensionRecord" minOccurs="0" maxOccurs="unbounded"/>
    </xs:sequence>
  </xs:complexType>
  <xs:complexType name="ExtensionRecord">
    <xs:sequence>
      <xs:element name="InformationName" type="NormalTextType" minOccurs="0"/>
      <xs:element name="InformationContent" type="LongTextType"/>
    </xs:sequence>
    <xs:attribute name="extensionId" type="xs:anySimpleType" use="optional"/>
  </xs:complexType>
  <xs:complexType name="VATRecord">
    <xs:sequence>
      <xs:element name="SumBeforeVAT" type="Decimal4FractionDigitsType"/>
      <xs:element name="VATRate" type="Decimal2FractionDigitsType"/>
      <xs:element name="VATSum" type="Decimal4FractionDigitsType"/>
    </xs:sequence>
  </xs:complexType>
  <xs:simpleType name="AccountType">
    <xs:restriction base="xs:string">
      <xs:maxLength value="35"/>
      <xs:pattern value="([0-9|A-Z])*"/>
    </xs:restriction>
  </xs:simpleType>
  <xs:simpleType name="CurrencyType">
    <xs:restriction base="xs:string">
      <xs:pattern value="[A-Z][A-Z][A-Z]"/>
    </xs:restriction>
  </xs:simpleType>
  <xs:simpleType name="DateType">
    <xs:restriction base="xs:date"/>
  </xs:simpleType>
  <xs:simpleType name="Decimal2FractionDigitsType">
    <xs:restriction base="xs:decimal">
      <xs:fractionDigits value="2"/>
    </xs:restriction>
  </xs:simpleType>
  <xs:simpleType name="Decimal4FractionDigitsType">
    <xs:restriction base="xs:decimal">
      <xs:fractionDigits value="4"/>
    </xs:restriction>
  </xs:simpleType>
  <xs:simpleType name="LongTextType">
    <xs:restriction base="xs:string">
      <xs:maxLength value="500"/>
    </xs:restriction>
  </xs:simpleType>
  <xs:simpleType name="NormalTextType">
    <xs:restriction base="xs:string">
      <xs:maxLength value="100"/>
    </xs:restriction>
  </xs:simpleType>
  <xs:simpleType name="NameTextType">
    <xs:restriction base="xs:string">
      <xs:maxLength value="70"/>
      <xs:pattern value="[&#x0020;-&#x00FF;]*"/>
    </xs:restriction>
  </xs:simpleType>
  <xs:simpleType name="RegType">
    <xs:restriction base="xs:string">
      <xs:maxLength value="15"/>
    </xs:restriction>
  </xs:simpleType>
  <xs:simpleType name="ReferenceType">
    <xs:restriction base="xs:string">
      <xs:maxLength value="20"/>
      <xs:pattern value="([0-9])*"/>
    </xs:restriction>
  </xs:simpleType>
  <xs:simpleType name="ShortTextType">
    <xs:restriction base="xs:string">
      <xs:maxLength value="20"/>
    </xs:restriction>
  </xs:simpleType>
  <xs:simpleType name="YesNoType">
    <xs:restriction base="xs:NMTOKEN">
      <xs:pattern value="YES"/>
      <xs:pattern value="NO"/>
    </xs:restriction>
  </xs:simpleType>
</xs:schema>
<!--
$Source: /export/cvsroot/hanza/einvoice-components/src/ee/hansa/einvoices/e-invoice.xsd,v $
$Author: tiimus $
$Date: 2005/10/05 05:56:30 $
$Modtime: 9.07.02 15:19 $
$Revision: 1.3 $
-->
